package com.feisi.service.impl;

import com.feisi.dao.CustomerDao;
import com.feisi.domain.Customer;
import com.feisi.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService {

    @Autowired
    private CustomerDao customerDao;

    @Override
    public List<Customer> findAll(Integer page, Integer limit) {
        List<Customer> customers = customerDao.findAll(page, limit);
        return customers;
    }

    @Override
    public Integer customerTotal() {
        Integer customerTotal = customerDao.customerTotal();
        return customerTotal;
    }

    @Override
    public List<Customer> findByName(String cu_name, Integer page, Integer limit) {
        List<Customer> customers = customerDao.findByName(cu_name, page, limit);
        return customers;
    }

    @Override
    public Integer customerTotalByName(String cu_name) {
        Integer customerTotalByName = customerDao.customerTotalByName(cu_name);
        return customerTotalByName;
    }

    @Override
    public List<Customer> findByUserid(Integer userid, Integer page, Integer limit) {
        List<Customer> customers = customerDao.findByUserid(userid, page, limit);
        return customers;
    }

    @Override
    public Integer customerTotalByUserid(Integer userid) {
        Integer customerTotalByUserid = customerDao.customerTotalByUserid(userid);
        return customerTotalByUserid;
    }


    @Override
    public void saveCustomer(Customer customer) {
        customerDao.saveCustomer(customer);
    }

    @Override
    public void deleteCustomer(Integer[] ids) {
        customerDao.deleteCustomer(ids);
    }

    @Override
    public void updateCustomer(Customer customer) {
        customerDao.updateCustomer(customer);
    }

    @Override
    public Customer findCustomerById(Integer id) {
        Customer customer= customerDao.findCustomerById(id);
        return customer;
    }
}
